<div class="row">
    <div class="col-md-12">
        <div class="widget stacked">
             <div class="widget-header">
                <i class="icon-list"></i>
                <h3><?php echo isset($title_for_layout)?$title_for_layout:$this->l('List of Consultations'); ?></h3>
            </div> <!-- /.widget-header -->
            <div class="widget-content">
                 
            <form action="<?php echo base_url('Doctor/Consultation/'); ?>" method="get" style="width: 100%;">
                    <div class="form-group">
                        <span class="col-md-8">
                            <a class="btn btn-success" href="<?php echo base_url('Doctor/Consultation/start'); ?>"><?php echo $this->l('Start a consultation'); ?></a>
                        </span>
                        
                        <div id="search" class="col-md-4">
                            <label class="col-md-4" for="inputquery" style=" line-height: 34px; ">
                                <?php echo $this->l('Search'); ?>
                            </label>
                        
                            <div class="input-group">
                                <input id="inputquery" class="form-control" type="text" name="q" value="<?php //echo $q; ?>" />
                                <span class="input-group-btn">
                                    <button class="btn btn-primary" type="submit"><?php echo $this->l('Go!'); ?></button>
                                </span>
                            </div><!-- /input-group -->
                        </div>
                        <input type="hidden" name="filter_reset" value="1" />
                        <input type="hidden" name="order_reset" value="1" />
                    </div>
                    <div class="clearfix"></div>
                </form>
                <div class="collapse navbar-collapse navbar-ex1-collapse">
                    <ul class="nav navbar-nav navbar-right">
                        <li class="dropdown-submenu"><a tabindex="-1" href="<?php echo base_url('Doctor/Prescription/?filter_reset=1'); ?>"><?php echo $this->l('All consultations'); ?></a></li>
                        <li><a href="<?php echo base_url('Doctor/Consultation/?filter_by=status&filter_val=1'); ?>"><?php echo $this->l('Created'); ?></a></li>
                        <li><a tabindex="-1" href="<?php echo base_url('Doctor/Consultation/?filter_by=status&filter_val=2'); ?>"><?php echo $this->l('In payment'); ?></a></li>
                        <li><a tabindex="-1" href="<?php echo base_url('Doctor/Consultation/?filter_by=status&filter_val=3'); ?>"><?php echo $this->l('Pending'); ?></a></li>
                        <li><a tabindex="-1" href="<?php echo base_url('Doctor/Consultation/?filter_by=status&filter_val=4'); ?>"><?php echo $this->l('Ongoing'); ?></a></li>
                        <li><a tabindex="-1" href="<?php echo base_url('Doctor/Consultation/?filter_by=status&filter_val=5'); ?>"><?php echo $this->l('Bonus time'); ?></a></li>
                        <li><a tabindex="-1" href="<?php echo base_url('Doctor/Consultation/?filter_by=status&filter_val=6'); ?>"><?php echo $this->l('Completed'); ?></a></li>
                    </ul>
                </div><!-- /.navbar-collapse -->
                
                <br /> 
                <section id="tables">
                    <div class="page-header">
                        <h3><?php echo $title; ?></h3>
                    </div>
                <div class="table-responsive">
                    
                    <table class="table table-bordered table-condensed">
                        <thead>
                          <tr>
                            <th>#</th>
                            <th><?php echo $this->l('Status'); ?></th>
                            <th><?php echo $this->l('Type'); ?></th>
                            <th><?php echo $this->l('Patient'); ?></th>
                            <th><?php echo $this->l('Date'); ?></th>
                            <th><?php echo $this->l('Actions'); ?></th>
                          </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($consultations as $key => $value) { ?>
                                <tr>
                                    <td><?php echo $value->id_consultation; ?></td>
                                    <td><?php echo $value->cons_status_label; ?></td>
                                    <td><?php echo $value->cons_type_label; ?></td>
                                    <td><?php echo $value->patient_name; ?></td>
                                    <td>
                                        <?php $date = date_create_from_format('Y-m-d H:i:s', $value->date_add);
                                        echo date_format($date, 'd F Y').' at ';
                                        echo date_format($date, 'H:i A'); ?>
                                    </td>
                                    <td>
                                    	<a class="btn btn-xs btn-success <?php if (!in_array($value->last_id_history, array('3','4','5')) OR $value->patient_is_connected == 0) { ?>disabled<?php }  ?>" href="<?php echo site_url('Doctor/Consultation/StartConsultation/'.$value->id_consultation); ?>">
                                            <i class="icon icon-edit"></i>
                                            <?php echo $this->l('Start consultation'); ?>
                                        </a>                                  	
                                        <a class="btn btn-xs btn-primary" href="<?php echo site_url('Doctor/Patient/viewLogs/?consultation='.$value->id_consultation); ?>"><i class="icon icon-eye-open"></i></a>
                                    </td>
                                </tr>
                            <?php }  ?>                                                    
                        </tbody>
                    </table>
                    <?php //include(((BASEPATH == '/')?'':dirname(BASEPATH)).'/'.APPPATH.'views/Templates/pagination.php'); ?>
                </section>
                </div>
            </div><!-- box-content -->
        </div><!-- /.box -->
    </div><!-- /.col (MAIN) -->
</div>
